package com.blog.cloud.service.rec.blog;

import java.util.List;

import org.apache.commons.lang3.StringUtils;

import com.blog.cloud.comm.modal.pojo.BlogContent;
import com.blog.cloud.comm.modal.pojo.User;
import com.blog.cloud.comm.webutils.DateUtils;
import com.blog.cloud.dao.BlogContentDao;
import com.jfinal.plugin.activerecord.Page;

public class BlogContentService {
	
	
	public static BlogContentDao blogContentDao = new BlogContentDao();
	
	
	public void insert(BlogContent blogContent){
		blogContentDao.insert(blogContent);
	}
	
	public void setBlogContentVal(User user, String blogTitle, String blogType,
			String blogContent, String blogStatus, String serialId) {
		BlogContent blogObj = new BlogContent();
		blogObj.setSerialId(serialId);
		blogObj.setBlogTitle(blogTitle);
		blogObj.setBlogContent(blogContent);
		blogObj.setShowType(blogStatus);
		blogObj.setTagNo(blogType);
		blogObj.setClickNum("0");
		blogObj.setUpdateUserNo(user.getUserNo());
		blogObj.setUpdateUserName(user.getUserName());
		blogObj.setUpdateTime(DateUtils.getCurrDateTime());
		blogObj.setIsDelete("0"); // 1-删除
		this.insert(blogObj);
	}
	
	
	
	
	
	public void update(){
		blogContentDao.update(null);
	}
	
	
	public List<BlogContent> getBlogContentByUserNo(String userNo){
		return blogContentDao.geetBlogContentByUserNo(userNo);
	}
	
	public Page<BlogContent> getBlogPageInit(String userNo , String searchVal , int pageNumber , int pageSize){
		Page<BlogContent> pageInint = null;
		if(StringUtils.isNotEmpty(userNo)  ){
			pageInint= blogContentDao.pageInint(userNo, searchVal, pageNumber, pageSize);
		}
		
		return pageInint;
	}

	public BlogContent getBlogContentBySerialId(String serialId){
		return blogContentDao.geetBlogContentSerialId(serialId);
	}
}
